﻿using System;

namespace Dune.Business.Domain.AssemblyCodes
{
    public class AssemblyCodeKey : IEquatable<AssemblyCodeKey>
    {
        private string assemblyName;
        private string assemblyVersion;


        public AssemblyCodeKey()
        {
        }


        public AssemblyCodeKey(string assemblyName, string assemblyVersion)
        {
            if (assemblyName == null)
                throw new ArgumentNullException("assemblyName");

            if (assemblyVersion == null)
                throw new ArgumentNullException("assemblyVersion");

            this.assemblyName = assemblyName;
            this.assemblyVersion = assemblyVersion;
        }


        public string AssemblyName
        {
            get { return assemblyName; }
            set { assemblyName = value; }
        }

        public string AssemblyVersion
        {
            get { return assemblyVersion; }
            set { assemblyVersion = value; }
        }


        public bool Equals(AssemblyCodeKey assemblyCodeKey)
        {
            if (assemblyCodeKey == null) return false;
            return Equals(assemblyName, assemblyCodeKey.assemblyName) && Equals(assemblyVersion, assemblyCodeKey.assemblyVersion);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(this, obj)) return true;
            return Equals(obj as AssemblyCodeKey);
        }

        public override int GetHashCode()
        {
            return (assemblyName != null ? assemblyName.GetHashCode() : 0) + 29 * (assemblyVersion != null ? assemblyVersion.GetHashCode() : 0);
        }
    }


    public class AssemblyCode : BaseEntity<AssemblyCodeKey>
    {
        private byte[] code;
        private DateTime createDate;
        private DateTime modifyDate;

        public byte[] Code
        {
            get { return code; }
            set { code = value; }
        }

        public DateTime CreateDate
        {
            get { return createDate; }
            set { createDate = value; }
        }

        public DateTime ModifyDate
        {
            get { return modifyDate; }
            set { modifyDate = value; }
        }
    }
}